/*
 * @Author: zi.yang
 * @Date: 2024-11-07 09:19:37
 * @LastEditors: zi.yang
 * @LastEditTime: 2024-11-07 11:24:03
 * @Description: 
 * @FilePath: /save-gitee-img/api.js
 */

/**
 * 默认参数属性
 */
export const defaultProps = { url: 'data', msg: 'msg' }
/**
 * 默认文件名处理函数
 * @param {*} imgUrl 
 * @returns 
 */
export const defaultFileNameHandle = (imgUrl) => imgUrl.split('/').pop();

/**
 * 接口列表
 */
export const apiList = [
  {
    type: 'meinvpic',
    title: '美女',
    url: 'https://v2.api-m.com/api/meinvpic',
    prop: 'data'
  },
  {
    type: 'heisi',
    title: '黑丝',
    url: 'https://v2.api-m.com/api/heisi',
  },
  {
    type: 'baisi',
    title: '白丝',
    url: 'https://v2.api-m.com/api/baisi',
  },
  {
    type: 'acg/pc',
    title: '二次元',
    url: `https://v2.api-m.com/api/randomAcgPic?type=pc`,
  },
  {
    type: 'acg/mobile',
    title: '二次元',
    url: `https://v2.api-m.com/api/randomAcgPic?type=wap`,
  },
  {
    type: 'wallpaper',
    title: '壁纸',
    url: 'https://v2.api-m.com/api/wallpaper',
  },
  {
    type: 'girl',
    title: '美女2',
    url: 'https://api.52vmy.cn/api/img/tu/girl',
    props: { url: 'url', msg: 'msg' },
    fileNameHandler: (imgUrl) => {
      return new URL(imgUrl).pathname.split('/').pop() + '.jpg';
    },
  },
  {
    type: 'genshin',
    title: '原神',
    url: 'https://api.52vmy.cn/api/img/tu/yuan',
    props: { url: 'url', msg: 'msg' },
    fileNameHandler: (imgUrl) => {
      return new URL(imgUrl).pathname.split('/').pop() + '.jpg';
    },
  },
  {
    type: 'boy',
    title: '男图',
    url: 'https://api.52vmy.cn/api/img/tu/boy',
    props: { url: 'url', msg: 'msg' },
    fileNameHandler: (imgUrl) => {
      return new URL(imgUrl).pathname.split('/').pop() + '.jpg';
    },
  },
  {
    type: 'cartoon',
    title: '动漫',
    url: 'https://api.52vmy.cn/api/img/tu/man',
    props: { url: 'url', msg: 'msg' },
    fileNameHandler: (imgUrl) => {
      return new URL(imgUrl).pathname.split('/').pop() + '.jpg';
    },
  },
  {
    type: 'video/yujn/baisi',
    title: '视频-白丝',
    url: 'https://api.yujn.cn/api/baisis.php?type=json',
    fileNameHandler: (imgUrl) => {
      const name = new URL(imgUrl).pathname.split('/').pop()
      return name.substring(name.lastIndexOf('=') + 1);
    },
  },
  {
    type: 'video/yujn/heisi',
    title: '视频-黑丝',
    url: 'https://api.yujn.cn/api/heisis.php?type=json',
    fileNameHandler: (imgUrl) => {
      const name = new URL(imgUrl).pathname.split('/').pop()
      return name.substring(name.lastIndexOf('=') + 1);
    },
  },
  {
    type: 'video/yujn/manzhan',
    title: '视频-漫展',
    url: 'https://api.yujn.cn/api/manzhan.php?type=json',
    fileNameHandler: (imgUrl) => {
      const name = new URL(imgUrl).pathname.split('/').pop()
      return name.substring(name.lastIndexOf('=') + 1);
    },
  },
  {
    type: 'cosplay',
    title: 'cosplay',
    url: 'https://api.dzzui.com/api/cosplay?format=json',
    props: { url: 'imgurl', msg: 'msg' },
    fileNameHandler: (imgUrl) => {
      return imgUrl.substring(imgUrl.indexOf('cosplay') + 8);
    },
  },
];